<template>
  <!-- 会员客户管理修改 -->
    <el-dialog title="修改" :visible.sync="openMemberManageCilentEdit" width="450px" append-to-body :destroy-on-close="true" :before-close="beforeClose">
      <el-form ref="form" :model="formParams" label-width="160px" v-show="showSearch" :inline="true">
        <el-form-item label="客户" prop="allName">
          <el-input
            v-model="formParams.allName"
            :disabled="true"
          />
        </el-form-item>
        <el-form-item label="状态" prop="zt">
          <el-select
            v-model="formParams.zt"
            placeholder="请选择状态"
            clearable
            >
              <el-option
                  v-for="item in status"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
              />
           </el-select>
        </el-form-item>
        <el-form-item label="是否代售" prop="issell">
          <el-select
            v-model="formParams.issell"
            placeholder="请选择是否代售"
            clearable
            >
              <el-option
                  v-for="item in isSell"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
              />
           </el-select>
        </el-form-item>
        <el-form-item label="预约出仓是否审核" prop="issh">
          <el-select
            v-model="formParams.issh"
            placeholder="请选择预约出仓是否审核"
            clearable
            >
              <el-option
                  v-for="item in previewWarehouseOutAudit"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
              />
           </el-select>
        </el-form-item>
        <el-row class="mt20" type="flex" justify="center">
          <el-col :span="1.5">
            <el-button type="primary" size="mini" @click="handleEdit" v-hasPermi="['zhcloud:shop:modify']">修 改</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
</template>

<script>
import { memberManageCilentModify  }  from "@/api/storage/memberManageCilent";


export default {
  name: "MemberManageCilentEdit",
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      //弹窗状态
      openMemberManageCilentEdit:false,
      //状态
      status:[
        {label:"启用状态", value:"启用状态"},
        {label:"停用状态", value:"停用状态"},
      ],
      //是否代售
      isSell:[
        {label:"是", value:"1"},
        {label:"否", value:"0"},
      ],
      //预约出仓是否审核
      previewWarehouseOutAudit:[
         {label:"是", value:"1"},
        {label:"否", value:"0"},
      ],
      //显示参数
      formParams: {},
      // 查询参数
      submitParams: {
        aid: "",
        issell: "",
        issh: "",
        line: "",
        zt: ""
      },
    };
  },
  methods: {
    /**修改 */
    handleEdit() {
       const submitParams = this.submitParams
      const formParams = this.formParams
      for(let i in submitParams) {
        submitParams[i] = formParams[i]
        
      }
      this.$modal.loading("数据正在修改中，请稍等...")
      memberManageCilentModify(this.submitParams).then(response => {
        this.$modal.closeLoading()
        this.close()
        this.$emit('refresh', true)
      }).catch(()=> {
        this.$modal.closeLoading()
      })
    },

    /**改变窗口状态 */
    changeMemberManageCilentEdit() {
      this.openMemberManageCilentEdit = !this.openMemberManageCilentEdit;
    },
    /**重置数据 */
    reset(vm) {
      Object.assign(vm.$data, vm.$options.data())
    },
    /**关闭弹窗 */
    beforeClose(done) {
      this.close()
      done()
    },
    /**关闭弹窗 */
    close() {
      this.changeMemberManageCilentEdit()
      this.reset(this)
    },
    /**打开弹窗 */
    open(data) {
      this.changeMemberManageCilentEdit()
      this.formParams = {
        aid: data.id,
        issell: data.issellt == "是"?"1":"0",
        issh: data.issht == "是"?"1":"0",
        line: data.line,
        zt: data.zt,
        allName:data.allname
      }
    }
  }
};
</script>
